@extends('admin.layout.master')
@section('content')
    <!-- TAB NAVIGATION -->
    <ul class="nav nav-tabs" role="tablist">
        <li class="active"><a href="#tab1">标签列表</a></li>
        <li><a href="/admin/tag/create">新增标签</a></li>
    </ul>
    <form action="" method="post" class="form-horizontal" role="form">
        @csrf
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">标签管理</h3>
            </div>
            <div class="panel-body">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th width="100">编号</th>
                        <th>标签</th>
                        <th>修改日期</th>
                        <th width="120">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($data as $k)
                        <tr>
                            <td>{{$k['id']}}</td>
                            <td>{{$k['name']}}</td>
                            <td>{{$k['updated_at']}}</td>
                            <td>
                                <div class="btn-group btn-group-sm">
                                    <a href="/admin/tag/{{$k['id']}}/edit" class="btn btn-primary">编辑</a>
                                    <a href="javascript:;"  onclick="del({{$k['id']}})" class="btn btn-danger">删除</a>
                                </div>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>

        </div>
        <div class="mt-3">
            {{$data->links()}}
        </div>
    </form>

    <script>
        function del(id) {
            require(['util'],function () {
                util.confirm('确认删除吗',function () {
                    $.ajax({
                        url:'/admin/tag/'+id,
                        method:'DELETE',
                        success:function (response) {
                            util.message(response.message,'refresh');
                        }
                    })
                })
            })
        }
    </script>
@endsection
